/**
 * @author abid.hussain
 */
exports.GAServerResponseCommonModel = Core.Class.subclass({
	classname: 'GAServerResponseCommonModel',
	initialize : function(serverResponse){
		this._signature = null;
		this._customAttributes = null;
		this._currencyUpdated = null;
		this._defaultGame = null;
		this._device = null;
		this._devStat = null;
		this._appsalar = null;
		this._showAds = null;
		this._firstGameState = null;
		this._game = null;
		this._gameId = null;
		this._gameServer = null;
		this._inAppenAbled = null;
		this._offerServer = null;
		this._requestType = null;
		this._serverTime = null;
		this._status = null;
		this._storeServer = null;
		this._superUser = null;
		this._offersUrl = null;
		this._appurl = null;
		this._checkOutServer = null;
		this._qaUser = null;
		this._socialServer = null;
		this._currentTime = null;
		this._timeDifference = null;
		this._pnsurl = null;
		this._isActive = null;
		this._notificationServer = null;
		this._serverResponse = serverResponse;
		this._parseServerResponseTag();
	},
	_parseServerResponseTag : function(){
		if(this._serverResponse != 'undefined' && this._serverResponse != null){
			this._signature = this._serverResponse['Signature'];
			var customAttr = this._serverResponse['custom_attributes'];
			if( customAttr != 'undefined' && customAttr != null){
				this._customAttributes = eval("(" + customAttr + ")");
			}
			this._checkOutServer =  this._serverResponse['@checkoutserver'];
			this._currencyUpdated = this._serverResponse['@currencyupdated'];
			this._defaultGame = this._serverResponse['@default_game'];
			this._device = this._serverResponse['@device'];
			this._devStat = this._serverResponse['@devstat'];
			this._appsalar = this._serverResponse['@appsalar'];
			this._showAds = this._serverResponse['@showads'];
			this._game = this._serverResponse['@game'];
			this._gameId = this._serverResponse['@game_id'];
			this._gameServer = this._serverResponse['@gameserver'];
			this._requestType = this._serverResponse['@requesttype'];
			this._inAppenAbled = this._serverResponse['@inappenabled'];
			this._offerServer = this._serverResponse['@offerserver'];
			this._qaUser = this._serverResponse['@qauser'];
			this._serverTime = this._serverResponse['@servertime'];
			this._timeDifference = this.calculateTimeDifferenceFromServer(this._serverTime);
			this._socialServer = this._serverResponse['@socialserver'];
			this._status = 	this._serverResponse['@status'];
			this._storeServer = this._serverResponse['@storeserver'];
			this._superUser = this._serverResponse['@superuser'];
			this._pnsurl = this._serverResponse['@pnsurl'];
			this._appurl = this._serverResponse['@appurl'];
			this._isActive = this._serverResponse['@isactive'];
			this._notificationServer = this._serverResponse['@notificationserver'];
			this._qaUser = ( this._qaUser != null && this._qaUser.toLowerCase() == "yes".toLowerCase() ) ? true : false;
			this._superUser = ( this._superUser != null && this._superUser.toLowerCase() == "yes".toLowerCase() ) ? true : false;
		}
	},
	
	getSignature: function(){
		return this._signature;
	},
	getCustomAttributes: function(){
		return this._customAttributes;
	},
	getSocialServer: function(){
		return this._socialServer;
	},
	getStoreServer : function(){
		return this._storeServer;
	},
	getCheckOutServer : function(){
		return this._checkOutServer;
	},
	getCurrencyUpdated : function (){
		return this._currencyUpdated;
	},
	getDefaultGame : function (){
		return this._defaultGame;
	},
	getDevice : function (){
		return this._device;
	},
	getDevStat : function (){
		return this._devStat;
	},
	getGame : function (){
		return this._game;
	},
	getGameId : function (){
		return this._gameId;
	},
	getGameServer : function (){
		return this._gameServer;
	},
	getInAppenAbled : function (){
		return this._inAppenAbled;
	},
	getOfferServer : function (){
		return this._offerServer;
	},
	getRequesttype: function(){
		return this._requestType;
	},
	isQAUser : function (){
		return this._qaUser;
	},
	getServerTime : function (){
		return this._serverTime;
	},
	setServerTime : function(sTime) {
		this._serverTime = sTime;
		this._timeDifference = this.calculateTimeDifferenceFromServer(this._serverTime); //updating server time diff
	},
	getTimeDifference : function() {
		return this._timeDifference;
	},
	getStatus : function (){
		return this._status;
	},
	isSuperUser : function (){
		return this._superUser;
	},
	getAppsalar : function(){
		return this._appsalar;
	},
	getShowAds: function(){
		return this._showAds;
	},
	getPnsUrl: function(){
		return this._pnsurl;
	},
	getAppUrl: function(){
		return this._appurl;
	},
	getIsActive: function(){
		return this._isActive;
	},
	getNotificationServer : function (){
		return this._notificationServer;
	},
	calculateTimeDifferenceFromServer: function(serverTime) {
		var sTime = 0;
		if(!serverTime || serverTime.length!=0) {
			sTime = parseFloat(serverTime);
		}
		var today = new Date();
    	var currentDateInSec = today.getTime()/1000; //timeIntervalSince1970
														  
		return (sTime - currentDateInSec);
		//return (currentDateInSec - sTime );												  
	},
	destroy : function(){
		this._signature = null;
		this._customAttributes = null;
		this._currencyUpdated = null;
		this._defaultGame = null;
		this._device = null;
		this._devStat = null;
		this._appsalar = null;
		this._showAds = null;
		this._firstGameState = null;
		this._game = null;
		this._gameId = null;
		this._gameServer = null;
		this._inAppenAbled = null;
		this._offerServer = null;
		this._requestType = null;
		this._serverTime = null;
		this._status = null;
		this._storeServer = null;
		this._superUser = null;
		this._offersUrl = null;
		this._appurl = null;
		this._checkOutServer = null;
		this._qaUser = null;
		this._socialServer = null;
		this._currentTime = null;
		this._timeDifference = null;
		this._pnsurl = null;
		this._isActive = null;
		this._serverResponse = null;
	}
});